cmake_minimum_required(VERSION 3.10)
project(ScreenCapture VERSION 1.0.0)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Set Windows minimum version to support XP
add_definitions(-D_WIN32_WINNT=0x0501)
add_definitions(-DWINVER=0x0501)
add_definitions(-D_WIN32_IE=0x0600)

# Configure static runtime library
if(MSVC)
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
    set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
endif()

# Include directories
include_directories(include)

# Source files
set(SOURCES
    src/ScreenCapture.cpp
    src/GDICapture.cpp
    src/DXGICapture.cpp
    src/DesktopMonitor.cpp
    src/BMPSaver.cpp
    src/SecureDesktopCapture.cpp
    src/SystemServiceCapture.cpp
    src/Utils.cpp
)

# Header files
set(HEADERS
    include/ScreenCapture.h
    include/GDICapture.h
    include/DXGICapture.h
    include/DesktopMonitor.h
    include/BMPSaver.h
    include/SecureDesktopCapture.h
    include/SystemServiceCapture.h
    include/Utils.h
)

# Create static library
add_library(ScreenCapture STATIC ${SOURCES} ${HEADERS})

# Link libraries
target_link_libraries(ScreenCapture
    gdi32
    user32
    kernel32
    d3d11
    dxgi
    advapi32
    shell32
)

# Example executables
add_executable(ScreenCaptureExample examples/main.cpp)
target_link_libraries(ScreenCaptureExample ScreenCapture)

add_executable(ScreenCaptureService examples/service_main.cpp)
target_link_libraries(ScreenCaptureService ScreenCapture)

# Set output directories
set_target_properties(ScreenCapture PROPERTIES
    ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/lib/Debug"
    ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/lib/Release"
)

set_target_properties(ScreenCaptureExample PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin/Debug"
    RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin/Release"
)

set_target_properties(ScreenCaptureService PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin/Debug"
    RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin/Release"
)